package com.siberhus.tdfl.processor;

import com.siberhus.tdfl.CancelException;
import com.siberhus.tdfl.FieldDataException;
import com.siberhus.tdfl.mapping.LineMapper;
import com.siberhus.tdfl.transform.FieldSet;

public abstract class AbstractDataFileProcessor<T> implements DataFileProcessor<T>{
	
	private LineMapper<T> lineMapper;
	
	public void setLineMapper(LineMapper<T> lineMapper){
		this.lineMapper = lineMapper;
	}
	
	@Override
	public void afterLoading() {}

	@Override
	public void beforeLoading() {}
	
	@Override
	public void onStart() throws Exception{}
	
	@Override
	public void onFinish() throws Exception{}
	
	@Override
	public T mapLine(FieldSet fs, FieldDataException fde) throws Exception {
		
		return lineMapper.mapLine(fs, fde);
	}
	
	@Override
	public void update(){}
	
	@Override
	public void onItemError(T item, Exception e){}
	
	@Override
	public void onItemSuccess(T item){}
	
	@Override
	public void onCancel(CancelException e) {}
	
	@Override
	public void onInterrupt(InterruptedException e) {}
	
}
